
#import "SMMineAddressViewController.h"
#import <Masonry/Masonry.h>
@implementation SMMineAddressViewController {
    NSArray *_data;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"地址管理";
    self.view.backgroundColor=UIColor.systemGroupedBackgroundColor;
    self.tableView.backgroundColor=UIColor.systemGroupedBackgroundColor;
    self.tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAddr)];
    _data=@[@{@"name":@"张三",@"phone":@"138****5678",@"addr":@"江苏省苏州市工业园区星湖街 666 号 A 栋"},
            @{@"name":@"李四",@"phone":@"139****8888",@"addr":@"上海市浦东新区张江路 123 号 3 层"}];
}
- (void)addAddr {
    UIAlertController *ac=[UIAlertController alertControllerWithTitle:@"新增地址" message:@"此处进入新增地址表单" preferredStyle:UIAlertControllerStyleAlert];
    [ac addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
    [self presentViewController:ac animated:YES completion:nil];
}
- (NSInteger)tableView:(UITableView*)t numberOfRowsInSection:(NSInteger)s{ return _data.count; }
- (CGFloat)tableView:(UITableView*)t heightForRowAtIndexPath:(NSIndexPath*)i{ return 72; }
- (UITableViewCell*)tableView:(UITableView*)t cellForRowAtIndexPath:(NSIndexPath*)i{
    UITableViewCell *c=[t dequeueReusableCellWithIdentifier:@"c"]; if(!c) c=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"c"];
    NSDictionary *d=_data[i.row]; c.textLabel.text=[NSString stringWithFormat:@"%@  %@", d[@"name"], d[@"phone"]];
    c.detailTextLabel.text=d[@"addr"]; c.detailTextLabel.numberOfLines=2;
    c.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return c;
}
@end
